package com.central.common.exception;

import lombok.Getter;

@Getter
public enum BizExceptionEnum {
    SUCCESS(200, "操作成功"),
    SERVER_ERROR(500, "服务器异常"),

    PARAM_NOT_NULL(204, "参数不能为空"),
    ACCOUNT_PASSWORD_ERROR(205, "账号密码错误"),
    INVALID_SYMBOL(206, "包含非法字符"),
    DB_RECORD_EXISTS(209, "数据库中已存在该记录"),
    TOKEN_INVALID(210, "token失效，请重新登录"),
    ACCOUNT_LOCK(211, "账号被锁定"),
    UNAUTHORIZED(212, "未授权"),
    SC_UNAUTHORIZED(213, "登陆异常"),
    IDENTIFIER_NOT_NULL(214, "验证码uuid不能为空"),
    CAPTCHA_ERROR(215, "验证码错误"),
    ACCOUNT_DISABLE(216, "账号被禁用"),
    PASSWORD_ERROR(217, "密码错误"),
    TOKEN_NOT_EMPTY(218, "token不能为空"),
    USERNAME_EXIT(219, "账号已经被使用"),
    X_TENANT_ID_IS_NULL(220, "组织码为空"),
    DATA_IS_NULL(221, "数据不存在"),
    ILLEGAL_CHARACTER(222, "数据包含非法字符"),
    DATA_SCOPE_PARAMS_ERROR(223, "数据范围出错"),
    JOB_ERROR(224, "定时任务出错"),






    ;

    BizExceptionEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private Integer code;

    private String message;


    public void setCode(Integer code) {
        this.code = code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static BizExceptionEnum getEnum(int code) {
        for (BizExceptionEnum ele : BizExceptionEnum.values()) {
            if (ele.getCode() == code) {
                return ele;
            }
        }
        return null;
    }
}
